
const { createWebAPIRequest } = require('../../util/util')
module.exports = [
  {
    /**
    * @api {get} /music/like [喜欢歌曲]
    * @apiGroup Music
    * @apiPermission none
    * @apiParam {Number} id  id
    * @apiParam {Boolean} [like=true] 是否喜欢
    * @apiParam {Number} [time=25]
    * @apiParam {String} [alg=itembased]
    */
    url: '/music/like',
    request: (req, res) => {
      const cookie = req.get('Cookie') || ''
      const trackId = req.query.id
      const like = req.query.like || true
      const alg = req.query.alg || 'itembased'
      const time = req.query.time || 25
      const data = {
        csrf_token: '',
        trackId,
        like
      }
      createWebAPIRequest(
        'music.163.com',
        `/weapi/radio/like?alg=${alg}&trackId=${trackId}&like=${like}&time=${time}`,
        'POST',
        data,
        cookie,
        musicReq => res.send(musicReq),
        err => res.status(500).send({err})
      )
    }
  }, {
    /**
    * @api {get} /music/likelist [喜欢歌曲列表]
    * @apiGroup Music
    * @apiPermission none
    * @apiParam {String} uid
    */
    url: '/music/likelist',
    request: (req, res) => {
      const cookie = req.get('Cookie') || ''
      const data = {
        uid: req.query.uid,
        csrf_token: ''
      }
      createWebAPIRequest(
        'music.163.com',
        `/weapi/song/like/get`,
        'POST',
        data,
        cookie,
        musicReq => {
          res.send(musicReq)
        },
        err => res.status(500).send({err})
      )
    }
  }
]
